<template>
  <view class="activity-comment-hierarchical-for-comment-publish-page st-bg-color-white">
    <commentPublish :subject-id="subjectId" :target-user-id="targetUserId" :group-flag="$config.activityGroupFlag" @saveSuccess="goBack" @publishSuccess="goBack"></commentPublish>
  </view>
</template>

<script>
import commentPublish from '../../../../../../../components/comment/web/components/app/uni-app/st-u-comment-hierarchical-for-subject-publish/st-u-comment-hierarchical-for-subject-publish.vue'
export default {
  components: {commentPublish},
  data(){
    return {
      // 上一个页面传递一评论id
      subjectId: '',
      // 是哪一个用户
      targetUserId: ''
    }
  },
  onLoad(options){
    this.subjectId = options.subjectId
    this.targetUserId = options.targetUserId
  },
  methods: {
    // 只有发布成功才有 comment 参数
    goBack(comment){
      // 延时一下返回，因为动作太快，导致提示信息一闪而过
      setTimeout(()=>{
        uni.navigateBack({
          delta: 1,
          success(res){
            // 向上个页面传递发布完的数据
            if (comment) {
              uni.$emit('activity_commentHierarchicalForCommentPublishSuccess', comment)
            }
          }
        })
      },1000)
    },
  }

}
</script>

<style scoped>
page{
  background-color: #FFFFFF;
}
</style>